//
//  UIbubuttonItem.swift
//  ZQWeibo
//
//  Created by summer的Dad on 16/11/12.
//  Copyright © 2016年 summer的Dad. All rights reserved.
//


import UIKit

   extension UIBarButtonItem {
    
    
    convenience init(title : String = "" , imageName : String ,target: Any?, action: Selector?) {
        
        let btn = UIButton ()
        
        //颜色
        btn.setTitle(title, for: .normal)
        btn.setTitleColor(UIColor .darkGray, for: .normal)
        
        btn.setTitleColor(UIColor .orange, for: .selected)
        //字体
    
        btn.titleLabel?.font = UIFont .boldSystemFont(ofSize: 14)
        //设置按钮

            btn.setImage(UIImage(named:imageName), for: .normal)
            
            btn.setImage(UIImage(named:imageName+"_highlighted"), for: .selected)
            

        
        //监听事件
        if let ac = action {
        btn.addTarget(target, action:ac, for: .touchUpInside)
 
        }
        btn.sizeToFit()
        
        
        self.init ()
        self.customView = btn
    }
    
    
    
}
 
